package com.yunfei.yunhetong.constractSignLog.controller;

import com.yunfei.utils.log.BaseLog;
import com.yunfei.utils.page.PageUtil;
import com.yunfei.utils.string.StringUtil;
import com.yunfei.yunhetong.constractSignLog.bo.ConstractSignLogBo;
import com.yunfei.yunhetong.constractSignLog.service.ConstractSignLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

;
   /**
    *@tablename constractsignlog
    *@author zhengyunfei
    *@createDate Fri Aug 30 13:13:39 CST 2019
    */ 
	@Controller
	@RequestMapping("/constractSignLog")
	public class ConstractSignLogController{
	@Autowired
	private ConstractSignLogService constractSignLogService;

	/**
	*查询所有信息
	*@author zhengYunFei
	*@date Fri Aug 30 13:13:39 CST 2019
	*/
	@RequestMapping(value = "/findAllListPage.shtml",produces = "text/html;charset=UTF-8",method =  RequestMethod.POST)
	@ResponseBody
	public Object findAllListPage(ConstractSignLogBo bo,String field, String order,String pageNum,String pageSize){
		Object jsonStr="";
		try {
				/************* 分页处理 ************/
			int skip;
			int max;
			if (StringUtil.isNullOrEmpty(pageNum))
			pageNum = "0";
			if (StringUtil.isNullOrEmpty(pageSize))
			pageSize = "20";
			skip = Integer.parseInt(pageNum);
			max = Integer.parseInt(pageSize);
			/************  分页处理结束 ***********/
			int total=0;
			bo.setCurNo((skip-1)*max+1);
			bo.setCurSize(skip*max);
			bo.setField(ConstractSignLogBo.changeFieldColumn(field));
			bo.setOrder(order);
			total=constractSignLogService.count(bo);
			List<ConstractSignLogBo> list = constractSignLogService.findAllListPage(bo);
			jsonStr = PageUtil.getPageJson(pageNum, pageSize, max, total, list);
		} catch (Exception e) {
			e.printStackTrace();
			BaseLog.e(this.getClass(), "queryArticleList:查询有误", e);
		}
		return jsonStr;
	}

}

